//
//  ZYCAttendanceExportRecordsCell.m
//  ZDSC
//
//  Created by 张威 on 2021/10/26.
//

#import "ZYCAttendanceExportRecordsCell.h"

@interface ZYCAttendanceExportRecordsCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *lookButton;

@end
@implementation ZYCAttendanceExportRecordsCell

- (void)setFilePath:(NSString *)filePath{
    _filePath = filePath;
    _titleLabel.text = filePath;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.lookButton];
    
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.lookButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-20.0f);
            make.centerY.equalTo(self.contentView);
        }];
        
    }
    return self;
}


- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 18.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}


- (UIButton *)lookButton {
    if (!_lookButton) {
        _lookButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_lookButton setTitle:@"查看" forState:UIControlStateNormal];
        [_lookButton setTitleColor:HEX_RGB(@"333333") forState:UIControlStateNormal];
        [_lookButton addTarget:self action:@selector(clickLookAction:) forControlEvents:UIControlEventTouchUpInside];
        _lookButton.titleLabel.font = kCustomFont(@"PingFangSC-Regular", 15.0f);
    }
    return _lookButton;
}


- (void)clickLookAction:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(attendanceExportRecordsCellDidPreview:)]) {
        [self.delegate attendanceExportRecordsCellDidPreview:self.filePath];
    }
}

@end
